package cn.xd.security.config;


import cn.xd.security.exception.MainAccessDeniedHandler;
import jakarta.annotation.Resource;
import org.springframework.security.config.Customizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExceptionHandlingConfigurer;
import org.springframework.stereotype.Component;

/**
 * @author : mirzaLin
 * @date : 2024/1/29
 * @description :
 **/
@Component
public class MainExceptionHandlingConfigurer implements Customizer<ExceptionHandlingConfigurer<HttpSecurity>> {
    @Resource
    private MainAccessDeniedHandler mainAccessDeniedHandler;

    @Override
    public void customize(ExceptionHandlingConfigurer<HttpSecurity> httpSecurityExceptionHandlingConfigurer) {
        httpSecurityExceptionHandlingConfigurer.accessDeniedHandler(mainAccessDeniedHandler);
    }
}
